<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>快吃管理系统</title>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/main.css"/>
    <script type="text/javascript" src="__PUBLIC__/js/libs/modernizr.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-3.2.1.min.js"></script>
    <script src="__PUBLIC__/js/layer/layer.js"></script>

</head>
<body style="margin:0px;padding:0px">
<style type="text/css" media="screen">
.total{
    width:100%;
    height: 100%;
    background-color: #B3B3B3;
    position: fixed;
    top:0px;
    opacity:0.5;
    margin:0px;
    z-index: 2;
    display:none;
}    
.add{
    width:500px;
    height:220px;
    background-color: #fff;
    position:fixed;
    top:50px;
    left:30%;
    border-radius: 5px;
z-index: 300;
display: none;
}
.add span
{
    float:right;
    font-size: 30px;
    margin-top: 10px;
    margin-right: 20px;
    color:#666;
    cursor: pointer;
}
.add span:hover
{
    color:#aaa;
}
.add p
{
    font-size: 18px;
    float:left;
    margin-top: 40px;
    margin-left:200px;
    color:#000;
    font-family: '微软雅黑';

}
.addtab
{
    float:left;
/*    margin-top:10px;*/
    margin-left: 90px;
}
.addtab tr
{
    float:left;
    margin-top: 20px;
    width:300px;
}
.addtab th
{
    width:90px;
    font-size: 15px;
    font-family: '微软雅黑';
    color:#000;
    float:left;
    font-weight:normal;
}
.addtab input
{
    border-radius: 5px;
    float:left;
}
.btn12
{
    width:160px;
    height:40px;
    letter-spacing: 10px;
    font-size: 16px;
  
}
.require-red {
    color: #f60;
    font-family: serif;
    margin-right: 3px;
}
</style>
<div class="total">
</div>
<div class="add" id="add">
<span onclick="ad()">×</span>
<p>新增菜品类型</p>
<form id="myform">
<table  class="addtab">
<tr><th><i class="require-red">*</i>菜品分类名称：</th><td><input name='food_class_name' type='text'  placeholder="菜品分类名称"></td></tr>
<tr><th></th><td><input class="btn btn-primary btn6 btn12 suba" name="sub" value="添加" type="button"></td></tr>
</table>
</form>

</div>
<p style="margin-top:15px;margin-left:40px; font-size:16px; border-left:3px #006dcc solid; padding-left:5px">查看所有菜品分类</p>
<div class="container clearfix">
    <div class="main-wrap">
        <div class="search-wrap">
            <div class="search-content">
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="javascript:;" onclick="ad()"><i class="icon-font"></i>新增菜品分类</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%" id="addto">
                        <tr>
                            <th>菜品分类ID</th>
                            <th>菜品分类名称</th>
                            <th>操作</th>
                        </tr>
                        {volist name="data" id="v"}
                        <tr>
                            <td>{$v.food_class_id}</td>
                            <td>{$v.food_class_name}</td>
                            <td>
                       <a class="link-del" href="javascript:;" onclick="dele('{$v.food_class_id}')">删除</a>
        
                            </td>
                            </tr>
                            {/volist}
                    </table>
                    <!-- <div class="list-page"> 2 条 1/1 页</div> -->
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function ad()
    {
        $('.total').toggle(500);
        $('#add').toggle(1000);

    }



function dele(food_class_id){
        $.get("{:url('Foodclass/deletefun')}",{food_class_id:food_class_id}, function(data) {
            if(data.code=='1')
            {
                location.reload();        
            }
        else
           layer.msg(data.message, { offset: ['0px', '40%'], icon:5,time:2000});    
            
        });

    }

    $('.suba').click(function()
        {
        var food_class_name=$('input[name=food_class_name]');
        if(food_class_name.val()=="")
        {
            layer.msg('菜品分类名称不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            food_class_name.focus();
            return ;
        }


        var formData = new FormData($("#myform")[0]);//获取表单数据        
          $.ajax({
               url: "{:url('Foodclass/addfun')}",//提交地址
               type: 'POST',
               data: formData,
               async: false,
               cache: false,
               contentType: false,
               processData: false,
               success: function (returndata) {
                if(returndata.code=='1'){
                    

                  layer.msg(returndata.message, { offset: ['0px', '40%'], icon:6,time:1000},function(){
                    location.reload(); 
                  });
                }
                else
                layer.msg(returndata.message, { offset: ['0px', '40%'], icon:5,time:2000});            
               },
               error: function (returndata) {
                layer.msg(returndata.message, { offset: ['0px', '40%'], icon:5,time:2000});

           }
          });     

        });
</script>
</html>